<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
    <style>
        .msg{
            background-color: blue;
        }
        .error{
            visibility: hidden;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- <div @click="isMsg = !isMsg" class="a" :class="{a:true,msg:isMsg}">{{msg}}</div> -->
        <!-- <div @click="isMsg = !isMsg" class="a" :class="classes">{{msg}}</div> -->
        <div  :class="arr">{{msg}}</div>
        <button @click="changeArr">changeArr</button>
    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                msg:"hello",
                isMsg:true,
                arr:['msg','error'],
                obj:{
                    b:true,
                    c:true
                }
            },
            methods:{
                changeArr(){
                    this.arr.length===2 ? this.arr.pop() : this.arr.push('error')
                }
            },
            computed:{
                classes:function(){
                    return {
                        a:true,
                        msg:this.isMsg,
                        ...this.obj  //剩余参数
                    }
                }
            }
        })
    </script>
</body>
</html>